package com.controller;

import com.dao.UserMapper;
import com.model.User;
import com.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;

@Controller
@RequestMapping("uc")
public class UserController {
    @Autowired
    UserService userService;

    @RequestMapping("queryUser.do")
    @ResponseBody
    public HashMap<String, Object> queryUserList(User user,String page, String limit) {
        HashMap<String, Object> map = new HashMap<>();
        HashMap<String, Object> browMap = userService.queryAllUser(user,page, limit);
        map.put("code", 0);
        map.put("msg", "");
        map.put("count", browMap.get("total"));
        map.put("data", browMap.get("list"));
        return map;
    }

    //    修改用户的部分信息
    @RequestMapping("updateUser.do")
    @ResponseBody
    public void updateUser(User user) {
        userService.updateUser(user);
    }

    //根据用户id删除用户
    @RequestMapping("delUser.do")
    @ResponseBody
    public void delUser(String userid) {
        int userId = Integer.parseInt(userid);
        userService.delectUserByUserId(userId);
    }
    //根据当前用户名，查询用户信息
    @RequestMapping("selectUser.do")
    @ResponseBody
    public List<User> selectUserByUserName(String userName){

        return null;
    }
}
